home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / EDITORS / AE170.ZIP;1 / AE0.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-09-07  |  19.4 KB  |  350 lines

  1. UNIT AE0 ;
  2.  
  3. {$R-}
  4. {$B-}
  5. {$I-}
  6. {$S+}
  7. {$V-}
  8.  
  9. {-----------------------------------------------------------------------------}
  10. { This unit contains the definitions of all constants, types                  }
  11. { and global variables                                                        }
  12. {-----------------------------------------------------------------------------}
  13.  
  14. INTERFACE
  15.  
  16. USES Crt, Dos ;
  17.  
  18. CONST MaxNrOfWorkspaces = 3 ;     { maximum number of workspaces }
  19.       WsBufSize         = 65534 ; { maximum size of workspace buffer }
  20.       PasteBufSize      = 16384 ; { maximum size of paste buffer }
  21.       MaxMacroLength    = 100 ;   { maximum number of keystrokes in a macro }
  22.       NrOfMacros        = 10 ;    { number of macros }
  23.       MacroStackDepth   = 10 ;    { maximum size of macro stack }
  24.       PosStackDepth     = 10 ;    { maximum size of position stack }
  25.       Inactive          = 0 ;     { generally used value }
  26.       NrOfCursorTypes   = 4 ;     { number of cursor available types }
  27.       UnderLineCursor   = 1 ;     { cursor type }
  28.       HalfBlockCursor   = 2 ;     { cursor type }
  29.       BlockCursor       = 3 ;     { cursor type }
  30.       NoBlinkCursor     = 4 ;     { cursor type }
  31.       NrOfColorSettings = 9 ;     { size of ScreenColorArray }
  32.       LinesOnScreen     = 25 ;    { number of lines on a screen }
  33.       NrOfTextLines     = 24 ;    { = LinesOnScreen - 1 }
  34.       ColsOnScreen      = 80 ;    { number of columns on a screen }
  35.       CharsOnScreen     = 2000 ;  { number of characters on a screen (25*80) }
  36.       BkspKey           = 264 ;   { keynumber of Backspace key }
  37.       TabKey            = 265 ;   { keynumber of Tab key }
  38.       CtrlReturnKey     = 266 ;   { keynumber of Control-Return key }
  39.       ReturnKey         = 269 ;   { keynumber of Return (= Enter) key }
  40.       EscapeKey         = 283 ;   { keynumber of Escape key }
  41.       TAB               = #9  ;   { tab character (ASCII value 9 }
  42.       LF                = #10 ;   { line feed character (ASCII value 10) }
  43.       FF                = #12 ;   { form feed character (ASCII value 12) }
  44.       CR                = #13 ;   { carriage return character (ASCII value 13) }
  45.       EF                = #26 ;   { end-of-file character (ASCII value 26) }
  46.       ESC               = #27 ;   { escape character (ASCII value 27) }
  47.       ConfigFilename    = 'AE.CFG' ; { name of file containing setup settings }
  48.       Find              = 1 ;     { used to indicate search type }
  49.       FindAndReplace    = 2 ;     { used to indicate search type }
  50.       MaxFileListLength = 100 ;   { maximum number of files that can be in }
  51.                                   { a file list }
  52.       MaxHistLength     = 10 ;    { maximum number of lines in a history }
  53.       WorkFilename      = 'AE.WRK' ; { name of file with saved workspace }
  54.       UpCompatSetupVersion = '1.63' ; { earliest setup verion that is upward
  55.                                         compatible with current version }
  56.       UpCompatWorkVersion = '1.61' ; { same for work file }
  57.  
  58.  
  59. TYPE Position       = RECORD Index       : WORD ;
  60.                              Linenr      : WORD ;
  61.                              Colnr       : WORD ;
  62.                              END ;
  63.                       { a position within a workspace buffer is stored in two }
  64.                       { ways: an index for the array (of type WsBuftype) and }
  65.                       { a line number plus column number }
  66.      WsBuftype      = ARRAY [1..WsBufSize] OF CHAR ;
  67.      WsBufPtr       = ^WsBuftype ;
  68.      Workspacetype  = RECORD
  69.                          Name             : PathStr ;
  70.                          ChangesMade      : BOOLEAN ;
  71.                          LastTimeSaved    : ARRAY [1..4] OF WORD ;
  72.                                             { hrs,mins,secs,1/100 secs }
  73.                          CurPos           : Position ;
  74.                                             { current position }
  75.                          MARK             : WORD ;
  76.                                             { index of block mark }
  77.                          FirstVisibleLine : Position ;
  78.                                             { points to start of first line }
  79.                                             { that is shown on screen }
  80.                          FirstScreenCol   : WORD ;
  81.                          VirtualColnr     : WORD ;
  82.                                             { column nr that CurPos should }
  83.                                             { be on when moving through    }
  84.                                             { buffer vertivally            }
  85.                          Buffer           : WsBufPtr ;
  86.                          BufferSize       : WORD ;
  87.                                             { number of chars in buffer }
  88.                          PosStack         : ARRAY [1..PosStackDepth] OF WORD;
  89.                                             { position stack }
  90.                          PosStackPointer  : BYTE ;
  91.                              END ;
  92.      PasteBuftype   = ARRAY [1..PasteBufSize] OF CHAR ;
  93.      SetupBlock     = RECORD Banner          : STRING [12] ;
  94.                              Version         : STRING [4] ;
  95.                              CursorType      : BYTE ;
  96.                              Keyclick        : BOOLEAN ;
  97.                              ScreenColors    : BYTE ;
  98.                              FastRedraw      : BOOLEAN ;
  99.                              SoundBell       : BOOLEAN ;
  100.                              PageLength      : WORD ;
  101.                              LeftMargin      : WORD ;
  102.                              TopMargin       : WORD ;
  103.                              PrintPageNrs    : BOOLEAN ;
  104.                              WordWrapLength  : WORD ;
  105.                              AutoWrap        : BOOLEAN ;
  106.                              TabSpacing      : WORD ;
  107.                              AutoIndent      : BOOLEAN ;
  108.                              DotsForSpaces   : BOOLEAN ;
  109.                              InsertMode      : BOOLEAN ;
  110.                              SaveOnExit      : BOOLEAN ;
  111.                              SaveInterval    : WORD ;
  112.                              MakeBAKfile     : BOOLEAN ;
  113.                              SaveWork        : BOOLEAN ;
  114.                              END ;
  115.      MacroBlock        = RECORD Contents      : ARRAY [1..NrOfMacros,
  116.                                                        1..MaxMacroLength]
  117.                                                        OF WORD ;
  118.                                 LENGTH        : ARRAY [1..NrOfMacros] OF WORD ;
  119.                                 END ;
  120.      ConfigBlock       = RECORD Setup : SetupBlock ;
  121.                                 Macro : MacroBlock ;
  122.                                 END ;
  123.      MacroStackElement = RECORD Macronr : BYTE ;
  124.                                 Index   : BYTE ;
  125.                                 END ;
  126.      { the following types are defined because most information is written }
  127.      { directly into video memory }
  128.      ScreenArray    = ARRAY [1..LinesOnScreen, 1..ColsOnScreen] OF WORD ;
  129.      ScreenPtr      = ^ScreenArray ;
  130.      ScreenBlock    = ARRAY [1..CharsOnScreen] OF WORD ;
  131.      ScreenBlockPtr = ^ScreenBlock ;
  132.      ScreenElement  = RECORD Contents  : CHAR ;
  133.                              Attribute : BYTE ;
  134.                              END ;
  135.      ScreenElementPtr = RECORD
  136.                              CASE BYTE OF
  137.                                   0 : (Ref : ^ScreenElement) ;
  138.                                   1 : (OFS, SEG : WORD) ;
  139.                              END ;
  140.      ColorSetting   = RECORD NormAttr         : BYTE ;
  141.                              BlockAttr        : BYTE ;
  142.                              StatusAttr       : BYTE ;
  143.                              CursorAttr       : BYTE ;
  144.                              StatusCursorAttr : BYTE ;
  145.                              END ;
  146.                       { contains the attributes used on the screen: }
  147.                       { NormAttr for normal characters, }
  148.                       { BlockAttr for characters within the selected block, }
  149.                       { StatusAttr for characters on the status line, }
  150.                       { CursorAttr for the non-blinking block cursor, }
  151.                       { StatusCursorAttr for same within status line }
  152.      FilenameStr    = STRING [12] ;
  153.                       { contains the name of a file plus extension }
  154.      stringptr      = ^STRING ;
  155.      History        = RECORD MaxLineLen : BYTE ;
  156.                                           { max length of lines in history }
  157.                              Len        : BYTE ;
  158.                                           { current number of lines }
  159.                              LINE       : ARRAY [1..MaxHistLength]
  160.                                                OF stringptr ;
  161.                              CurLine    : BYTE ;
  162.                                           { current line }
  163.                              END ;
  164.      HistPtr        = ^History ;
  165.      WorkBlock      = RECORD Banner           : STRING [12] ;
  166.                              Version          : STRING [4] ;
  167.                              NrOfWorkSpaces   : BYTE ;
  168.                              CurrentWsnr      : BYTE ;
  169.                              FileName         : ARRAY [1..MaxNrOfWorkspaces]
  170.                                                   OF PathStr ;
  171.                              CursorPos        : ARRAY [1..MaxNrOfWorkspaces]
  172.                                                  OF Position ;
  173.                              FirstVisibleLine : ARRAY [1..MaxNrOfWorkspaces]
  174.                                                  OF Position ;
  175.                              FirstScreenCol   : ARRAY [1..MaxNrOfWorkspaces]
  176.                                                  OF WORD ;
  177.                              END ;
  178.  
  179.  
  180. CONST DefaultSetup : { default setup, used if no setup file is found }
  181.                      { in the current directory }
  182.                      SetupBlock = (
  183.                             Banner          : ConfigFilename ;
  184.                             Version         : '1.00' ;
  185.                             CursorType      : UnderLineCursor ;
  186.                             Keyclick        : FALSE ;
  187.                             ScreenColors    : 3 ;
  188.                             FastRedraw      : FALSE ;
  189.                             SoundBell       : TRUE ;
  190.                             PageLength      : Inactive ;
  191.                             LeftMargin      : 0 ;
  192.                             TopMargin       : 0 ;
  193.                             PrintPageNrs    : FALSE ;
  194.                             WordWrapLength  : Inactive ;
  195.                             AutoWrap        : FALSE ;
  196.                             TabSpacing      : 0 ;
  197.                             AutoIndent      : TRUE ;
  198.                             DotsForSpaces   : FALSE ;
  199.                             InsertMode      : TRUE ;
  200.                             SaveOnExit      : FALSE ;
  201.                             SaveInterval    : Inactive ;
  202.                             MakeBAKfile     : FALSE ;
  203.                             SaveWork        : FALSE ) ;
  204.       ScreenColorArray : { contains the screen color settings that can be }
  205.                          { chosen from. Only the first two are available }
  206.                          { for monochrome video adapters }
  207.                          ARRAY [1..NrOfColorSettings] OF ColorSetting =
  208.                            {1} ( (NormAttr : LightGray + Black * 16 ;
  209.                                  BlockAttr : Black + LightGray * 16 ;
  210.                                  StatusAttr : White + Black * 16 ;
  211.                                  CursorAttr : Black + LightGray * 16 ;
  212.                                  StatusCursorAttr : Black + LightGray * 16) ,
  213.                            {2}  (NormAttr : LightGray + Black * 16 ;
  214.                                  BlockAttr : Black + LightGray * 16 ;
  215.                                  StatusAttr : Black + LightGray * 16 ;
  216.                                  CursorAttr : Black + LightGray * 16 ;
  217.                                  StatusCursorAttr : LightGray + Black * 16) ,
  218.                            {3}  (NormAttr : LightGray + Blue * 16 ;
  219.                                  BlockAttr : White + Cyan * 16 ;
  220.                                  StatusAttr : Blue + LightGray * 16 ;
  221.                                  CursorAttr : White + Magenta * 16 ;
  222.                                  StatusCursorAttr : White + Magenta * 16) ,
  223.                            {4}  (NormAttr : LightGray + Blue * 16 ;
  224.                                  BlockAttr : White + Magenta * 16 ;
  225.                                  StatusAttr : Yellow + LightGray * 16 ;
  226.                                  CursorAttr : White + Cyan * 16 ;
  227.                                  StatusCursorAttr : White + Cyan * 16) ,
  228.                            {5}  (NormAttr : Black + LightGray * 16 ;
  229.                                  BlockAttr : LightGray + Blue * 16 ;
  230.                                  StatusAttr : White + Red * 16 ;
  231.                                  CursorAttr : LightGray + Black * 16 ;
  232.                                  StatusCursorAttr : LightGray + Black * 16) ,
  233.                            {6}  (NormAttr : LightGray + Black * 16 ;
  234.                                  BlockAttr : Black + LightGray * 16 ;
  235.                                  StatusAttr : Red + LightGray * 16 ;
  236.                                  CursorAttr : LightGray + Red * 16 ;
  237.                                  StatusCursorAttr : LightGray + Red * 16) ,
  238.                            {7}  (NormAttr : Green + Black * 16 ;
  239.                                  BlockAttr : Black + LightGray * 16 ;
  240.                                  StatusAttr : White + LightGray * 16 ;
  241.                                  CursorAttr : Black + Green * 16 ;
  242.                                  StatusCursorAttr : Black + Green * 16) ,
  243.                            {8}  (NormAttr : Cyan + Black * 16 ;
  244.                                  BlockAttr : LightGray + Blue * 16 ;
  245.                                  StatusAttr : Red + LightGray * 16 ;
  246.                                  CursorAttr : Black + Cyan * 16 ;
  247.                                  StatusCursorAttr : Black + Cyan * 16) ,
  248.                            {9}  (NormAttr : Yellow + Blue * 16 ;
  249.                                  BlockAttr : Blue + LightGray * 16 ;
  250.                                  StatusAttr : Black + LightGray * 16 ;
  251.                                  CursorAttr : Red + LightGray * 16 ;
  252.                                  StatusCursorAttr : Red + LightGray * 16) ) ;
  253.       { frame constant used as border string in calls of PutFrame }
  254.       Quasi3DFrame : STRING [8] = '⁄ƒ∑∫ºÕ‘≥' ;
  255.       { categories of characters, for text formatting etc. }
  256.       WordDelimiters : SET OF CHAR = [' ', CR, LF, TAB] ;
  257.       WordPunctuators : SET OF CHAR = [',', '.', ':', ';', '[', ']',
  258.                                        '(', ')', '{', '}', '/', 
  259.                                        '\', '+', '-', '=', '"', #39 ] ;
  260.       { constants used for constructing the statusline }
  261.       Status_Wrap   : STRING [4] = 'Wrap' ;   { indicates word wrap }
  262.       Status_Ins    : STRING [3] = 'Ins' ;    { indicates insert mode }
  263.       Status_Def    : STRING [3] = 'Def' ;    { on when defining a macro }
  264.       Status_Indent : STRING [6] = 'Indent' ; { indicates autoindent }
  265.       { basis for constructing the statusline }
  266.       BasicStatusLine : STRING [80] =
  267.                          '   L       C                            ' +
  268.                          '                     Ovr               %' ;
  269.       { string used to display CR/LF pair when entering search string }
  270.       CRLFalias : STRING [2] = #17 + #217 ;
  271.  
  272. VAR AEVersionNr        : STRING [4] ;
  273.     AEVersionDate      : STRING [12] ;
  274.     ProgramFinished    : BOOLEAN ;
  275.                          { indicates if user has given command to exit AE }
  276.     Config             : ConfigBlock ;
  277.     Workspace          : ARRAY [1..MaxNrOfWorkspaces] OF Workspacetype ;
  278.     NrOfWorkspaces     : BYTE ;
  279.                          { actual number of workspaces; may be less than }
  280.                          { MaxNrOfWorkspaces if not enough memory }
  281.     CurrentWsnr        : BYTE ;
  282.                          { contains number of the current workspace }
  283.     CurrentWs          : Workspacetype ;
  284.                          { copy of Workspace[CurrentWsnr] ; used to }
  285.                          { avoid one level of indirection }
  286.     PasteBuffer        : ^PasteBuftype ;
  287.     PasteBufferSize    : WORD ;
  288.                          { contains number of characters in paste buffer }
  289.     MacroStack         : ARRAY [1..MacroStackDepth] OF MacroStackElement ;
  290.                          { macro stack is necessary because macros can call }
  291.                          { other macros }
  292.     MacroStackPointer  : BYTE ;
  293.     MacroDefining      : BYTE ;
  294.                          { number of the macro that is currently being }
  295.                          { defined (when 0: not defining any) }
  296.     FindString         : STRING ;
  297.     ReplaceString      : STRING ;
  298.     SearchOptions      : STRING [10] ;
  299.     SearchType         : BYTE ;
  300.     ColorCard          : BOOLEAN ;
  301.                          { indicates whether video adapter is monochrome }
  302.                          { or color }
  303.     OrigCursorType     : BYTE ;
  304.     OrigTextAttr       : BYTE ;
  305.                          { cursor type and video text attribute on startup }
  306.                          { are kept for restoration on exiting program }
  307.     MessageRead        : BOOLEAN ;
  308.                          { indicates if the message on the status line has }
  309.                          { been read by the user }
  310.                          { set by Message, reset by GetKeyNr }
  311.     LoadfileName       : PathStr ;
  312.                          { contains name of last file to be read or inserted }
  313.     EscPressed         : BOOLEAN ;
  314.                          { indicates whether last call of EnterString, }
  315.                          { EnterWord, EnterBoolean, Answer or Choose was }
  316.                          { terminated by user by pressing Escape }
  317.     Found              : BOOLEAN ;
  318.                          { indicates whether last search operation or }
  319.                          { bracket matching was succesful }
  320.     IgnoreCase         : BOOLEAN ;
  321.     ReverseSearch      : BOOLEAN ;
  322.     NoQuery            : BOOLEAN ;
  323.     WholeWords         : BOOLEAN ;
  324.                          { the current search options }
  325.     DiskError          : BYTE ;
  326.                          { contains result of last disk or print operation }
  327.                          { value 0: everything OK }
  328.     DisplayPtr         : ScreenPtr ;
  329.                          { points to begin of video memory }
  330.     StatusLinePtr      : ScreenPtr ;
  331.                          { points to begin of status line in video memory }
  332.     WordSeparators     : SET OF CHAR ;
  333.     FileHist           : HistPtr ; { history of file names loaded }
  334.     FindHist           : HistPtr ; { history of string searched }
  335.     ReplaceHist        : HistPtr ; { history of string replaced }
  336.     WorkFilePath       : PathStr ; { name of work file loaded at startup }
  337.     {$IFDEF DEVELOP }
  338.     InitMemAvail       : LONGINT ; { initially available heap memory }
  339.     BasicMemAvail      : LONGINT ; { above basic needs (1 workspace) }
  340.     StdMemAvail        : LONGINT ; { after creating all workspaces }
  341.     MinMemAvail        : LONGINT ; { always available during running }
  342.                          { used to compute minimum heap size needed }
  343.     {$ENDIF }
  344.  
  345. IMPLEMENTATION
  346.  
  347. BEGIN
  348. WordSeparators := WordDelimiters + WordPunctuators ;
  349. END.
  350.